(in-package #:experiment)

(defclass crosshair (state)
  ((duration :initarg :duration :accessor crosshair-duration)))

(defmethod gwee:draw-view ((view crosshair))
  (let ((x (truncate (gwee:view-width view) 2))
        (y (truncate (gwee:view-height view) 2)))
    (sdl:draw-vline x (- y 10) (+ y 10) :color (gwee:color 0 0 0))
    (sdl:draw-hline (- x 10) (+ x 10) y :color (gwee:color 0 0 0))
    (sdl:draw-vline (1- x) (- y 10) (+ y 10) :color (gwee:color 0 0 0))
    (sdl:draw-hline (- x 10) (+ x 10) (1- y) :color (gwee:color 0 0 0))
    (sdl:draw-vline (1+ x) (- y 10) (+ y 10) :color (gwee:color 0 0 0))
    (sdl:draw-hline (- x 10) (+ x 10) (1+ y) :color (gwee:color 0 0 0))))

(defmethod state-init (experiment (state crosshair))
  (log experiment 'start)
  (start-timer (crosshair-duration state)))

(defmethod state-dump append (experiment (state crosshair))
  `(:duration ,(crosshair-duration state)))

(define-action onward ((state crosshair)
                       (timeout))
  (state-onward *experiment* state))

(defmethod exp:state-list-actions append (experiment (state crosshair))
  (exp::default-list-actions state))
